<html>
<head>
    <title>透析助手</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.6/css/sm.min.css">
    <link rel="stylesheet" href="__PUBLIC__/css/style.css">
    <link rel="stylesheet" href="__PUBLIC__/css/5s.css">
    <link rel="stylesheet" href="__PUBLIC__/css/6m.css">
    <link rel="stylesheet" href="__PUBLIC__/css/iconfont.css">
</head>
<body>
    <div class="head">
        <div class="HeadContent">
			<a href="<{:U('Index/index')}>" class="backIndex"><i class="iconfont">&#xe605;</i></a>
            <a href="javascript:;" class="HeadTitle">个人信息</a>
        </div>
    </div>
    <div class="PersonalHead">
        <div class="PersonalHeadImg">
            <if condition="$userInfo['pic'] neq ''">
                <img src="<{$userInfo.pic}>" id="headImg" style="border-radius:50%;" />
            <else />
                <img src="__PUBLIC__/images/PersonalHeadImg.png" id="headImg" />
            </if>
        </div>
        <div class="PersonalName">
            <input type="text" value="<{$userInfo.name|default='匿名'}>" onblur="editInfo('name',$(this).val())" />
            <a href="<{:U('score')}>"> <span>我的积分</span> <i class="iconfont">&#xe60a;</i> </a>
        </div>
        <!--  <div class="PersonalCredits">
        <a href="#">
        <span>我的积分</span>
        <i class="iconfont">&#xe60a;</i>
        </a>
        </div> -->
    </div>
    <div class="PersonalInformation">
        <ul>
            <!-- <li>
                <a href="#">
                <div class="LeftTitle">
                    透析须知
                </div>
                <div class="RightContent">
                    <span>查看</span>
                    <i class="iconfont">&#xe60a;</i>
                </div> </a>
            </li> -->
            <li>
                <a href="javascript:void(0);">
                <div class="LeftTitle">
                    年龄
                </div>
                <div class="RightContent">
                    <input type="tel" value="<{$userInfo.age|default='0'}>" onblur="editInfo('age',$(this).val())" />
                    <i class="iconfont">&#xe60a;</i>
                </div> </a>
            </li>
			<li id="sex_chose" onclick="javascript:$('.sexPop').show();">
                <a href="javascript:;">
                <div class="LeftTitle">
                    性别
                </div>
                <div class="RightContent" >
                    <span id="sexSpan"><{:$userInfo['sex']==2 ? '女' : '男'}></span>
                    <i class="iconfont">&#xe60a;</i>
                </div> </a>
            </li>
            <li>
                <a href="javascript:;">
                    <div class="LeftTitle">透析中心</div>
                    <div class="RightContent"><span><{$htpRow.name}></span></div>
                </a>
            </li>
            <li>
                <a href="javascript:;">
                <div class="LeftTitle">
                    手机
                </div>
                <div class="RightContent">
                    <span><{$userInfo.phone}></span>
                </div> </a>
            </li>
            <li>
                <a href="javascript:;<{:U('Doctor/lists')}>">
                <div class="LeftTitle">
                    关联医生
                </div>
                <if condition="$userInfo['hpt_id'] eq 1">
                <div class="RightContent" onclick="location.href='<{:U('Chat/Index/system',array('sender'=>$userInfo['phone']))}>'"><span>无</span><i class="iconfont">&#xe60a;</i></div></a>
                <else />
                <div class="RightContent" onclick="location.href='<{:U('Doctor/lists')}>'"><span><{$docRow.name|default='无'}></span><i class="iconfont">&#xe60a;</i></div></a>
                </if>
            </li>
			<li>
                <a href="<{:U('Know/lists')}>">
                <div class="LeftTitle">
                    透析须知
                </div>
                <div class="RightContent" >
                    <span id="sexSpan">&nbsp;</span>
                    <i class="iconfont">&#xe60a;</i>
                </div> </a>
            </li>
        </ul>
    </div>
    <!-- 性别弹框开始 -->
	<div class="Popwindow sexPop">
      <div class="DinnerTime sex-chose">
        <div class="DinnerTime-title">性别</div>
        <div class="DinnerTime-list">
         <ul>
           <li>
              <a href="javascript:;">
                 <div class="LeftTitle">男</div>
                 <div class="RightContent">
                   <label class="sexLabel form-radio <{:$userInfo['sex']==1 ? 'active' : ''}>">
                     <i class="iconfont">&#xe610;</i>
                   </label>
                 </div>
              </a>
           </li>
           <li>
              <a href="javascript:;">
                 <div class="LeftTitle">女</div>
                 <div class="RightContent">
                   <label class="sexLabel form-radio <{:$userInfo['sex']==2 ? 'active' : ''}>">
                     <i class="iconfont">&#xe610;</i>
                   </label>
                 </div>
              </a>
           </li>
         </ul>
        </div>
        <div class="BtnGroup Btn-Popwindow NoFixed">
          <button class="btn-drop" onclick="javascript:$('.Popwindow').hide();">取消</button>
          <button class="btn-submit sexSubBtn">确定</button>     
        </div>
      </div>
    </div>
    <!-- 性别弹框结束 -->
    <!-- 上传照片iframe开始 -->
    <div style="visibility:hidden;width:100%;overflow-x:hidden;">
        <iframe name='img_frame' id="img_frame" style="visibility:hidden;height:1px"></iframe>
        <form id="img_form" action="<{:U('Admin/PicUpload/index')}>" encType="multipart/form-data" method="post" target="img_frame">
            <input type="file" name="pic" id="img_file" onchange="$('#img_form').submit();"/>
        </form>
    </div>
    <!-- 上传照片iframe结束 -->
    <!-- 加载动画 -->
    <div id="loadingBg" style="display:none;"></div>
<script type='text/javascript' src='__PUBLIC__/js/jquery-1.11.1.min.js'></script>
<script type='text/javascript' src='__PUBLIC__/js/myjq.js'></script>
<script>
    $(function(){
        $('#subBtn').click(function(){
            if(!isIdCode($('#card_num').val())){
                toast('请输入正确的身份证号');return;
            }
            if($('#card_pic_inp').val()==''){
                toast('请上传身份证照');return;
            }
            $.post('<{:U("idcard")}>',
                {id:'<{$uid}>',card_num:$('#card_num').val(),card_pic:$('#card_pic_inp').val()},
                function(res){
                    if(res=='suc'){
                        location.href="<{:U('Index/index')}>";
                    }else{
                        $.toast("保存失败");
                    }
                },
            'json');
        });
                
        //上传图片
        $("#headImg").click(function(){
            $('#loadingBg').show();
            $('#img_file').click()
        });
        $('#img_frame').load(function(){
            try{
                var iframeHtml = $(this).contents().find('body').html();
            }catch(e){
                var iframeHtml = window.frames["img_frame"].document.body.innerText;
            }
            $('#loadingBg').hide();
            var result = $.parseJSON(iframeHtml);
            if(result.msg=='suc'){
                $('#headImg').attr('src',result.url);
                editInfo('pic',result.url);//修改用户头像
            }else{
                alert(result.msg);
            }
        });
    
        //性别男女选中
        $('.sexLabel').click(function(){
            $('.sexLabel').removeClass('active');
            $(this).addClass('active');
        });
        //性别确定
        $('.sexSubBtn').click(function(){
            var sexName = $('.sexLabel.active').parent().siblings('.LeftTitle').text();
            var sexVal = (sexName == '男') ? '1' : '2';
            editInfo('sex',sexVal);//修改性别
            $('#sexSpan').text(sexName);
            $('.Popwindow').hide();
        });
    })
    
    //ajax修改用户信息
    function editInfo(name,val){
        $.post('<{:U("editUserInfo")}>',{name:name,val:val});
    }
</script>
</body>
</html>